<!--
  * 履约记录
  *
-->
<template>
  <div>
    <a-table :dataSource="tableData" :columns="columns" :pagination="false" rowKey="id" size="small" bordered>
      <template #bodyCell="{ text, record, index, column }">
        <template v-if="column.dataIndex === 'type'">
          <span>
            <a-tag :color="tagType[text]">{{ getDescByValue('GOODS_TYPE_ENUM', text) }}</a-tag>
          </span>
        </template>
      </template>
    </a-table>
  </div>
</template>
<script setup lang="ts">
import { reactive, watch, ref } from 'vue'
import { useEnums } from '@/hooks/plugins/useEnums'
const { getDescByValue } = useEnums()
const props = defineProps({
  enterpriseId: {
    type: Array,
    default: null
  }
})
const tagType = ref({
  1: 'error',
  2: 'warning',
  3: 'processing',
  4: 'success'
})
const columns = reactive([
  {
    title: '订单编号',
    dataIndex: ['fatherOrder', 'no']
  },
  {
    title: '商品',
    dataIndex: ['goods', 'goods_name']
  },
  {
    title: '规格',
    dataIndex: ['spec', 'spec_name']
  },
  {
    title: '单位',
    dataIndex: ['spec', 'unit_name']
  },
  {
    title: '订单时间',
    dataIndex: 'create_time'
  },
  {
    title: '履约数量',
    dataIndex: 'received_number'
  },
  {
    title: '履约金额(元)',
    dataIndex: 'received_money'
  }
])

const tableData = ref([])

watch(
  () => props.enterpriseId,
  (e) => {
    if (e) {
      tableData.value = e
    }
  },
  { immediate: true }
)
</script>
